var Loader = function () { };
Loader.prototype = {
    require: function (scripts, callback, type) {
        this.loadCount      = 0;
        this.totalRequired  = scripts.length;
        if(type!='css'){
            this.callback       = callback;
        }
        for (var i = 0; i < scripts.length; i++) {
            this.writeScript(scripts[i], type);
        }
    },
    loaded: function (evt) {
        this.loadCount++;
        if (this.loadCount == this.totalRequired && typeof this.callback == 'function') this.callback.call();
    },
    writeScript: function (src, type) {
        if(type=='css'){
            var s = document.createElement('link');
            s.href = src;
            s.rel = 'stylesheet';
            s.type = 'text/css';
            document.getElementsByTagName('head')[0].appendChild(s);
        }else{
            var self = this;
            var s = document.createElement('script');
            s.type = "text/javascript";
            s.async = true;
            s.src = src;
            document.getElementsByTagName('head')[0].appendChild(s);
            if (window.attachEvent){
                window.attachEvent('onload', function (e) { self.loaded(e); });
            }else{
                window.addEventListener('load', function (e) { self.loaded(e); }, false);
            }
        }
    }
};

function load_static_file(arr_css_files, arr_js_files, callback){
    var ld = new Loader();
    ld.require(
    arr_css_files,
    '',
    'css');
    ld.require(
    arr_js_files,
    function() {//callback function
        if (typeof callback == 'function') callback.call();
    },
    'js');
}
